# -*- coding: utf-8 -*-

import inode
import errno
import time
import os
import sys
import stat
import fuse

class Simple (fuse.Fuse):
	def __init__(self, *argv, **kw):
		fuse.Fuse.__init__(self, *argv, **kw)
		filename = None
		loglvl = 3
		if(filename == None):
			self.__fd_log = sys.stdout
		else:
			self.__fd_log = open (filename, 'w')
		self.__fd_loglvl = loglvl
		
		self.__table = {}
		
	def debug1(self, format, *others):
		if self.__fd_loglvl < 1 : return
		self.__fd_log.write((format + '\n') % others)
		
	def debug2(self, format, *others):
		if self.__fd_loglvl < 2 : return
		self.__fd_log.write((format + '\n') % others)
		
	def debug3(self, format, *others):
		if self.__fd_loglvl < 3 : return
		self.__fd_log.write((format + '\n') % others)
		
	def close(self):
		self.__fd.close()
		
		
	def getattr(self, path): 
		self.debug('GetAttr')
		st = fuse.Stat()
		st.st_mode = stat.S_IFDIR | 0755  
		st.st_nlink = 2
		st.st_atime = int(time.time())
		st.st_mtime = st.st_atime  
		st.st_ctime = st.st_atime    
		if path == '/':  
			self.debug(path)
			pass  
		else:  
			return - errno.ENOENT  
		return st  
		
	#def getattr (self, path):
		#print 'GetAttr'
		#inode = self.__table[path]
		#if (path == '/'):
			#inode_attr = Stat()
			#inode_attr.st_mode = stat.S_IFDIR
		#else:
			#if self.__table.has_key(path):
				#inode_attr = inode.metadata
			#else:
				#return -ENOENT

		#return inode_attr
		